<?php get_header(); ?>

<div id="content">

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

	<?php // Post dates off by default the_date('','<h2>','</h2>'); ?>
	<h2 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h2>
		<div class="meta"><?php _e("Posted in"); ?> <?php the_category(',') ?> by <?php the_author() ?> <?php _e('on') ?> <?php the_time('F jS, Y') ?> <?php edit_post_link(__('Edit This')); ?></div>

<?php if( !is_ads_free() ) { ?>
<div style="padding:10px 0 10px;">
<script type="text/javascript"><!--
google_ad_client = "<?php google_pub_id();?>";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_color_border = "ffffff";
google_color_bg = "ffffff";
google_color_link = "000000";
google_color_url = "808080";
google_color_text = "808080";;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<?php } ?>

	<div class="main">
		<?php the_content(__('(more...)')); ?>
	</div>
	<div class="tags">
	<?php the_tags(__('Tagged with: '),', ',' '); ?>
	</div>
<?php
$this_post = $post;
$category = get_the_category(); $category = $category[0]; $category = $category->cat_ID;
$posts = get_posts('numberposts=6&offset=0&orderby=post_date&order=DESC&category='.$category);
$count = 0;
foreach ( $posts as $post ) {
	if ( $post->ID == $this_post->ID || $count == 5)
		unset($posts[$count]);
	else
		$count ++;
}
?>
<?php if ( $posts ) : ?>
<div class="main">
<h3>See also:</h3>
<ul>
<?php foreach ( $posts as $post ) : ?>
<li><a rel="nofollow" href="<?php the_permalink() ?>" title="<?php echo trim(str_replace("\n"," ",preg_replace('#<[^>]*?>#si','',get_the_excerpt()))) ?>"><?php if ( get_the_title() ){ the_title(); }else{ echo "Untitled"; } ?></a> (<?php the_time('F jS, Y') ?>)</li>
<?php endforeach // $posts as $post ?>
</ul>
</div>
<?php endif // $posts ?>

	<div class="comments">
		<?php wp_link_pages(); ?>
		<?php comments_popup_link(__('no comments yet'), __('<strong>1</strong> comment'), __('<strong>%</strong> comments')); ?>
	</div>

<div class="navigation">
<div class="previous"><?php previous_post_link('&laquo; %link') ?></div>
<div class="next"><?php next_post_link('%link &raquo;') ?></div>
</div>

<?php if ( is_single() ) comments_template();
else if ( comments_open() ) comments_template(); ?>

<?php endwhile; else: ?>
<div class="warning">
	<p><?php _e('Sorry, no posts matched your criteria, please try and search again.'); ?></p>
</div>
<?php endif; ?>

<div id="postnav"><?php posts_nav_link(' &#8212; ', __('&laquo; Newer Posts'), __('Older Posts &raquo;')); ?></div>

</div> <!-- End content -->

<?php get_sidebar(); ?>

<div class="clearleft"></div>

<?php get_footer(); ?>